#include "GUIThread.h"

class GUIThread_Cleaner {
public:
    ~GUIThread_Cleaner() {
        GUIThread::destroy();
    }
} GUIThread_cleaner_instaninstce;

GUIThread* GUIThread::instance = NULL;

GUIThread::GUIThread()
{
    if(Debug::test(DEBUG_CREATE_DELETE)) {
        cout << "GUIThread Created" << endl;
    }
}

GUIThread* GUIThread::get_instance() {
    if(!instance) {
        instance = new GUIThread();
    }
    return instance;
}

void GUIThread::destroy() {
    if( !instance ) {
        return;
    }
    delete(instance);
    instance = NULL;
    if(Debug::test(DEBUG_CREATE_DELETE)) {
        cout << "GUIThread Destroyed" << endl;
    }
}

void GUIThread::execute() {
    showAndRun();
}

void GUIThread::showAndRun() {
    area.show();
    Gtk::Main::run(area);
}

GUIThread::~GUIThread() { }

